home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1 / Nebula One.iso / Mail / pine3.92 / pico / pilot.c < prev    next >
C/C++ Source or Header  |  1996-03-14  |  5KB  |  186 lines

  1. #if    !defined(lint) && !defined(DOS)
  2. static char rcsid[] = "$Id: pilot.c,v 4.5 1996/03/15 07:41:11 hubert Exp $";
  3. #endif
  4. /*
  5.  * Program:    Main stand-alone Pine File Browser routines
  6.  *
  7.  * Author:    Michael Seibel
  8.  *        Networks and Distributed Computing
  9.  *        Computing & Communications
  10.  *        University of Washington
  11.  *        Administration Building, AG-44
  12.  *        Seattle, WA  98195
  13.  *        Internet: mikes@cac.washington.edu
  14.  *
  15.  *
  16.  * Pine and Pico are registered trademarks of the University of Washington.
  17.  * No commercial use of these trademarks may be made without prior written
  18.  * permission of the University of Washington.
  19.  * 
  20.  * Pine, Pico, and Pilot software and its included text are Copyright
  21.  * 1989-1996 by the University of Washington.
  22.  * 
  23.  * The full text of our legal notices is contained in the file called
  24.  * CPYRIGHT, included with this distribution.
  25.  *
  26.  *
  27.  * BROWSER NOTES:
  28.  *
  29.  * 30 Sep 92 - Stand alone PIne's "Lister of Things" came into being.
  30.  *           It's built against libpico.a from a command line like:
  31.  *
  32.  *               cc pilot.c libpico.a -ltermcap -lc -o pilot
  33.  *
  34.  *           should it become a fleshed out tool, we'll move it into
  35.  *           the normal build process.
  36.  */
  37.  
  38. #include        <stdio.h>
  39. #include    "osdep.h"    /* operating system dependent includes */
  40. #include    "pico.h"    /* pine composer definitions */
  41. #include        "estruct.h"    /* global structures and defines */
  42. #include    "efunc.h"    /* function declarations and sans name table */
  43. #include    "edef.h"    /* global definitions */
  44.  
  45.  
  46. #define        PILOT_VERSION    "UW PILOT 1.0"
  47.  
  48.  
  49. extern char *gethomedir();
  50.  
  51.  
  52.  
  53. /*
  54.  * main standalone browser routine
  55.  */
  56. main(argc, argv)
  57. char    *argv[];
  58. {
  59.     register int    c;
  60.     register int    f;
  61.     register int    n;
  62.     register BUFFER *bp;
  63.     register int    carg;        /* current arg to scan         */
  64.     extern   int    pico_new_mail();
  65.     int         starton = 0;        /* where's dot to begin with?    */
  66.     int         i;
  67.     char     bname[NBUFN];        /* buffer name of file to read    */
  68.     char    *clerr = NULL;        /* garbage on command line    */
  69.     char     filename[NSTRING], filedir[NSTRING];
  70.  
  71.     timeout = 0;
  72.     Pmaster = NULL;            /* turn OFF composer functionality */
  73.     km_popped = 0;
  74.     opertree[0]     = '\0';
  75.     opertree[NLINE] = '\0';
  76.  
  77.     strcpy(filedir, gethomedir(NULL));
  78.     gmode |= MDBRONLY;            /* turn on exclusive browser mode */
  79.  
  80.     /*
  81.      * Read command line flags before initializing, otherwise, we never
  82.      * know to init for f_keys...
  83.      */
  84.     carg = 1;
  85.     while(carg < argc){
  86.     if(argv[carg][0] == '-'){
  87.         switch(argv[carg][1]){
  88.           case 'a':
  89.         gmode ^= MDDOTSOK;    /* show dot files */
  90.         break;
  91.           case 'f':            /* -f for function key use */
  92.         gmode ^= MDFKEY;
  93.         break;
  94.           case 'g':            /* show-cursor in file browser */
  95.         gmode ^= MDSHOCUR;
  96.         break;
  97.           case 'm':            /* turn on mouse support */
  98.         gmode ^= MDMOUSE;
  99.         break;
  100.           case 'n':            /* -n for new mail notification */
  101.         timeout = 180;
  102.         if(argv[carg][2] != '\0')
  103.           if((timeout = atoi(&argv[carg][2])) < 30)
  104.             timeout = 180;
  105.         break;
  106.           case 'o' :        /* operating tree */
  107.         if(argv[carg+1] && argv[carg+1][0] && argv[carg+1][0] != '-'){
  108.             strncpy(opertree, argv[++carg], NLINE);
  109.             gmode ^= MDTREE;
  110.         }
  111.         else{
  112.             printf("Missing or empty argument to -o flag isn't allowed\n");
  113.             exit(1);
  114.         }
  115.         break;
  116.           case 'v':            /* single column display */
  117.         gmode ^= MDONECOL;
  118.         break;
  119.           case 'x':            /* suppress keyhelp */
  120.         sup_keyhelp = !sup_keyhelp;
  121.         break;
  122.           case 'z':            /* -z to suspend */
  123.         gmode ^= MDSSPD;
  124.         break;
  125. #if    defined(DOS) || defined(OS2)
  126.           case 'c':            /* -c[nr][fb] colors */
  127.         if(carg + 1 < argc){
  128.             if(argv[carg][2] == 'n'){
  129.             if(argv[carg][3] == 'f')
  130.               pico_nfcolor(argv[++carg]);
  131.             else if(argv[carg][3] == 'b')
  132.               pico_nbcolor(argv[++carg]);
  133.             }
  134.             else if(argv[carg][2] == 'r'){
  135.             if(argv[carg][3] == 'f')
  136.               pico_rfcolor(argv[++carg]);
  137.             else if(argv[carg][3] == 'b')
  138.               pico_rbcolor(argv[++carg]);
  139.             }
  140.         }
  141.         else{
  142.             clerr = "insufficient args for \"-c\"";
  143.             break;
  144.         }
  145.         break;
  146. #endif
  147.           default:            /* huh? */
  148.         clerr = argv[carg];
  149.         break;
  150.         }
  151.         carg++;
  152.     }
  153.     else {                 /* dir to start in? */
  154.         strcpy(filedir, argv[carg]);
  155.         fixpath(filedir, NSTRING);
  156.         break;
  157.     }
  158.     }
  159.  
  160.     if(!vtinit())            /* Displays.            */
  161.       exit(1);
  162.  
  163.     strcpy(bname, "main");        /* default buffer name */
  164.     edinit(bname);            /* Buffers, windows.   */
  165. #if    defined(TERMCAP) || defined(TERMINFO) || defined(VMS)
  166.     if(pico_kbesc == NULL){        /* will arrow keys work ? */
  167.     (*term.t_putchar)('\007');
  168.     emlwrite("Warning: keypad keys may non-functional", NULL);
  169.     }
  170. #endif    /* TERMCAP/TERMINFO/VMS */
  171.  
  172.     curbp->b_mode |= gmode;        /* and set default modes*/
  173.     if(timeout)
  174.       emlwrite("Checking for new mail every %D seconds", (void *) timeout);
  175.  
  176.     if(clerr){                /* post any errors on command line */
  177.     if(mpresf)            /* show earlier message though! */
  178.       sleep(2);
  179.     emlwrite("\007Unknown option: %s", clerr);
  180.     }
  181.  
  182.     set_browser_title(PILOT_VERSION);
  183.     FileBrowse(filedir, filename, NULL, 0);
  184.     wquit(1, 0);
  185. }
  186.